package com.qf.dao.Impl;


import com.qf.dao.OrganDao;
import com.qf.entity.Organ;
import com.qf.util.DruidUtil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;


public class OrganDaoImpl implements OrganDao {
    private QueryRunner queryRunner = new QueryRunner();

    @Override
    public List<Organ> selectOrgan() {
        try {
            return queryRunner.query(DruidUtil.getConnection(), "select * from organ", new BeanListHandler<>(Organ.class));
        } catch (SQLException e) {
            throw new RuntimeException(e.getMessage() + "查询所有机构出现异常");
        }
    }
}
